<template>
  <div class="certification">
    <el-row>
      <el-col :span="24">
        <div class="certification-top">
          <div class="title">新增企业信息</div>
          <div class="tx"></div>
          <div class="mian">
            <el-form
              :model="ruleForm"
              :rules="rules"
              ref="ruleForm"
              label-width="100px"
              class="demo-ruleForm"
              :hide-required-asterisk="true"
            >
              <el-form-item label="企业名称" prop="name" class="s-input">
                <el-input v-model="ruleForm.name" placeholder="请输入企业名称" maxlength="50"></el-input>
              </el-form-item>
              <el-form-item label="证件类型" prop="region">
                <el-select
                  v-model="ruleForm.region"
                  placeholder="请选择"
                >
                  <el-option label="社会信用代码" value="MERGE"></el-option>
                  <el-option label="工商注册号" value="REGCODE"></el-option>
                  <el-option label="组织机构代码" value="NORMAL"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="证件号码" prop="registration" class="s-input">
                <el-input v-model="ruleForm.registration" maxlength="30" placeholder="请填写证件号码"></el-input>
              </el-form-item>
              <el-form-item>
                <el-button type="danger" @click="submitForm('ruleForm')"
                  >立即提交</el-button
                >
              </el-form-item>
            </el-form>
          </div>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
    data() {
      return {
        ruleForm: {
          name: '',
          region: '',
          registration:'',
        },
        rules: {
          name: [
            { required: true, message: '请输入企业名称', trigger: 'blur' },
            // { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
          ],
          region: [
            { required: true, message: '请选择类型', trigger: 'change' }
          ],
          registration: [
            { required: true, message: '请输入工商注册号', trigger: 'change' }
          ],
        }
      };
    },
    methods: {
      submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            this.confirm()
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
      },
      // 提交订单下一步
      confirm(){
        let {name,region,registration} = {...this.ruleForm}
        // this.$api.addCompany({name,organcode:registration,regtype:region}).then( res =>{
        //   if(res.code==20000){
        //     this.$message.success(res.msg)
        //     this.$router.push({ name: 'startcertification'});
        //   }else{
        //     this.$message.error(res.msg)
        //   }
          
        // })
        this.$router.push({ name: 'startcertification', params: {name,region,registration}});
      },
    }
  }
</script>

<style>
</style>